<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>定制活动列表</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="../../../component/elementUI/index.css">
    <link rel="stylesheet" href="../../../style/wangeditor.css">
    <link rel="stylesheet" href="../../../style/index.css">
    <style>
        .custom-tree-node {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: space-between;
            font-size: 14px;
            padding-right: 8px;
        }

        .custom-tree-node .config {
            padding: 10px 0 10px 8px;
        }
        .el-tree-node__content {
            padding: 10px 0 10px;
        }
        .cont-scroll-wrap {
            border: 1px solid #EBEEF5;
            flex: auto;
            height: 0;
            overflow-y: auto;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak class="minWidth">
        <el-form :inline="true" :form="form">
            <el-form-item>
                <el-button type="primary" @click="Add">新增活动</el-button>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="AddProject">新增项目</el-button>
            </el-form-item>
            <el-form-item>
                <el-input v-model.trim="form.Activity_Name" clearable placeholder="请输入活动名称"/>
            </el-form-item>
            <el-form-item>
                <el-select v-model.trim="form.Row_Status" clearable style="width: 100%;" placeholder="请选择发布状态">
                    <el-option v-for="item in Row_Status" :key="item.value" :label="item.label" :value="item.value"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-select v-model.trim="form.Status" clearable style="width: 100%;"
                    placeholder="请选择活动状态">
                    <el-option v-for="item in Status" :key="item.value" :label="item.label"
                        :value="item.value"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSerach">查询</el-button>
            </el-form-item>
            <el-form-item>
                <el-dropdown trigger="click" @command="downloadTemplate">
                    <el-button type="primary">
                        下载导入模板<i class="el-icon-arrow-down el-icon--right"></i>
                    </el-button>
                    <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item command="Article">导入活动商品模板</el-dropdown-item>
                    </el-dropdown-menu>
                </el-dropdown>
            </el-form-item>
            <el-form-item>
                <el-dropdown trigger="click" @command="importTemplate">
                    <el-button type="danger">
                        批量导入<i class="el-icon-arrow-down el-icon--right"></i>
                    </el-button>
                    <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item command="Article">导入活动商品</el-dropdown-item>
                    </el-dropdown-menu>
                </el-dropdown>
            </el-form-item>
        </el-form>
        <!-- 项目管理 -->
        <el-row :gutter="20">
            <el-col :span="isTree?5:0">
                <div :style="{height:'calc(100vh - 140px)'}" class="cont-scroll-wrap">
                    <el-tree highlight-current @node-click="handleNode" :data="treeData" node-key="Project_SerialNumber" default-expand-all
                        :expand-on-click-node="false" :props="defaultProps">
                        <span class="custom-tree-node" slot-scope="{ node, data }">
                            <span style="display: flex; align-items: center;">
                                <i style="margin-right: 10px;" :class="form.Project_SerialNumber==data.Project_SerialNumber? 'el-icon-folder-opened' :'el-icon-folder'"></i>
                                <el-tooltip class="item" effect="dark" :content="node.label+'('+data.Project_SerialNumber+') ' + data.Project_Notes" placement="right">
                                    <div style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">{{ node.label }}</div>
                                </el-tooltip>
                            </span>
                            <span class="config" @click.stop="">
                                <el-dropdown @command="clickProject($event,node,data)">
                                    <el-button type="primary" size="text">
                                        更多
                                    </el-button>
                                    <el-dropdown-menu slot="dropdown">
                                        <el-dropdown-item command="add">添加活动</el-dropdown-item>
                                        <el-dropdown-item command="edit">编辑</el-dropdown-item>
                                        <el-dropdown-item command="remove">删除</el-dropdown-item>
                                    </el-dropdown-menu>
                                </el-dropdown>
                            </span>
                        </span>
                    </el-tree>
                </div>
            </el-col>
            <!-- 活动管理 -->
            <el-col style="position: relative;" :span="isTree?19:24">
                <div @click="showTree" style="cursor: pointer; text-align: center; color:#606266; font-size: 12px; border: 1px solid #EBEEF5; position: absolute; left: -11px; top: 0px; width: 15px;">
                    {{isTree?'隐藏树状图←':'显示树状图→'}} 
                </div>
                <el-table :data="tableData" stripe border height="calc(100vh - 140px)" style="width: 100%">
                    <el-table-column align="center" type="index" label="序号" width="50"></el-table-column>
                    <el-table-column min-width="130" prop="Activity_SerialNumber" label="活动流水号"></el-table-column>
                    <el-table-column prop="Activity_Name" show-overflow-tooltip label="活动名称" min-width="120"></el-table-column>
                    <el-table-column prop="Project_Name" show-overflow-tooltip label="所属项目" min-width="120"></el-table-column>
                    <el-table-column prop="Row_Status" align="center" min-width="80"  label="发布状态">
                        <template v-slot="{row}">
                            {{row.Row_Status=='0'?'未发布':'已发布'}}
                        </template>
                    </el-table-column>
                    <el-table-column prop="Row_Status" align="center" min-width="80" label="活动状态">
                        <template v-slot="{row}">
                            {{row.Row_Status=='0'?'未发布':Type(row.Start_Date,row.End_Date)}}
                        </template>
                    </el-table-column>
                    <el-table-column prop="Department_Name" show-overflow-tooltip min-width="200" label="参与部门"></el-table-column>
                    <el-table-column prop="Activity_Notice" show-overflow-tooltip min-width="400" label="活动内容"></el-table-column>
                    <el-table-column prop="Start_Date" min-width="180" label="开始时间"></el-table-column>
                    <el-table-column prop="End_Date" min-width="180" label="结束时间"></el-table-column>
                    <el-table-column align="center" fixed="right" label="操作" width="180">
                        <template v-slot="{row}">
                            <el-button :type="row.Row_Status=='0'?'success':'info'" :disabled="row.Row_Status=='2'" size="small" @click="Publish(row)">发布</el-button>
                            <el-dropdown size="small" trigger="click" @command="config($event,row)">
                                <el-button size="small" type="primary">
                                    更多<i class="el-icon-arrow-down el-icon--right"></i>
                                </el-button>
                                <el-dropdown-menu slot="dropdown">
                                    <el-dropdown-item command="Edit">编辑</el-dropdown-item>
                                    <el-dropdown-item command="Remove">删除</el-dropdown-item>
                                    <el-dropdown-item command="ExportPointsLog">导出用户积分</el-dropdown-item>
                                    <el-dropdown-item command="ExportArticle">导出活动商品</el-dropdown-item>
                                </el-dropdown-menu>
                            </el-dropdown>
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination style="margin-top: 5px;" background @size-change="handleSizeChange"
                    @current-change="handleCurrentChange" :current-page="form.page" :page-sizes="[15, 30, 50, 100]"
                    :page-size="form.limit" layout="total, sizes, prev, pager, next, jumper" :total="total">
                </el-pagination>
            </el-col>
        </el-row>
        <add-project :visible.sync="visibleAddProject" @success="success"></add-project>
        <edit-project :id="Project_SerialNumber" :visible.sync="visibleEditProject" @success="success"></edit-project>
    </div>
    <script type="text/javascript" src="../../../utils/wangeditor.js"></script>
    <script type="text/javascript" src="../../../utils/jquery.min.js"></script>
    <script type="text/javascript" src="../../../utils/jquery.cookie.js"></script>
    <script type="text/javascript" src="../../../utils/vue.min.js"></script>
    <script type="text/javascript" src="../../../utils/vuex.min.js"></script>
    <script type="text/javascript" src="../../../component/elementUI/index.js"></script>
    <script type="text/javascript" src="../../../component/component.js"></script>
    <script type="text/javascript" src="../../../config/config.js"></script>
    <script type="text/javascript" src="../../../utils/compressor.js"></script>
    <script type="text/javascript" src="../../../utils/xlsx.full.min.js"></script>
    <script type="text/javascript" src="../../../utils/xlsx.core.min.js"></script>
    <script type="text/javascript" src="../../../utils/ID_Validity.js"></script>
    <script type="text/javascript" src="../../../utils/utils.js"></script>
    <script type="text/javascript" src="js/index.js"></script>
</body>

</html>